#ifndef __LOG_H__
#define __LOG_H__

#include <stdio.h>

#define LOG_LEVEL 3

#ifndef LOG_LEVEL
    #define log_info(fmt, args...)
    #define log_dbg(fmt, args...)
    #define log_err(fmt, args...)
#else

#if (LOG_LEVEL == 0)
 
    #define log_info(fmt, args...)                          \
        do {                                                \
            printf("%s %d: [info] ", __func__, __LINE__);     \
            printf(fmt, ##args);                            \
        } while(0)      
 
    #define log_dbg(fmt, args...)
    #define log_err(fmt, args...)
 
#elif (LOG_LEVEL == 1)
 
    #define log_info(fmt, args...)                          \
        do {                                                \
            printf("%s %d: [info] ", __func__, __LINE__);     \
            printf(fmt, ##args);                            \
        } while(0)
 
    #define log_dbg(fmt, args...)                           \
        do {                                                \
            printf("%s %d: [dbg ] ", __func__, __LINE__);     \
            printf(fmt, ##args);                            \
        } while(0)
 
    #define log_err(fmt, args...)
 
#elif (LOG_LEVEL == 2)
 
    #define log_info(fmt, args...)                          \
        do {                                                \
            printf("\x1B[1;32m %s %d: [info] ", __func__, __LINE__);     \
            printf(fmt, ##args);                            \
        } while(0)
 
    #define log_dbg(fmt, args...)                           \
        do {                                                \
            printf("\x1B[1;33m %s %d: [dbg ] ", __func__, __LINE__);     \
            printf(fmt, ##args);                            \
        } while(0)
 
    #define log_err(fmt, args...)                           \
        do {                                                \
            printf("\x1B[1;31m %s %d: [err ] ", __func__, __LINE__);     \
            printf(fmt, ##args);                            \
        } while(0)
#elif (LOG_LEVEL == 3)

    #define log_info(fmt, args...)                
    #define log_dbg(fmt, args...)
    #define log_err(fmt, args...)
#endif
				
#endif




void log_init(void);

#endif
